package com;

import java.net.URLClassLoader;

public class FileURL {
	private static String portsURL = null;
	private static String routeURL = null;
	private static String customURL = null;
	private static String XMLURL = null;

	private static String getPath(String SRC_FILE_PATH){
		try{
			URLClassLoader urlLoader = (URLClassLoader) FileURL.class.getClassLoader();
			String url = urlLoader.findResource(SRC_FILE_PATH).toString();
			url = url.replace("%20", " ");
			return  url.toString().substring(5, url.toString().length());			
		}catch(Exception ex){
			System.out.println("该索引文件未找到，请确认其位置是否存放正确！");
			ex.printStackTrace();
		}		
		return null;
	}
	
	public static String getPortsURL() {
		if(portsURL == null)
			portsURL  = getPath("../ports" );
		
		return portsURL;
	}

	public static String getRouteURL() {
		if(routeURL == null)
			routeURL = getPath("../route");
		
		return routeURL;
	}

	public static String getCustomURL() {
		if(customURL == null)
			customURL = getPath("../custom");
		return customURL;
	}
	
	public static String getXMLURL(){
		if(XMLURL == null)
			XMLURL = getPath("../Extend.xml");
		
		return XMLURL;
	}
}
